package com.csu.device.web;

import com.csu.analysis.service.GpsService;
import com.csu.device.service.HardWareService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.List;
import java.util.Map;


@CrossOrigin(origins = "*")
@Controller
public class GpsController {

    @Autowired
    private GpsService gpsService;

    @Autowired
    private HardWareService hardWareService;

    /**
     * 获取所有gps信息
     *
     * @return
     */
    @CrossOrigin(origins = "*")
    @ResponseBody
    @RequestMapping("/findAllGps")
    public List<Map<String, Object>> findAllGps() {
        return gpsService.findGpsAll();
    }

    /**
     * 获取老人活动轨迹
     *
     * @return
     */
    @CrossOrigin(origins = "*")
    @ResponseBody
    @RequestMapping("/gpsHis/{vdate}/{userId}")
    public List<Map<String, String>> gpsHis(@PathVariable("vdate") String vdate, @PathVariable("userId") String userId) {
        Map<String, Object> map = new HashMap<>();
        map.put("vdate", vdate);
        map.put("userId", userId);
        return hardWareService.gpsHis(map);
    }


    /**
     * 获取老人床垫历史数据
     * @param vdate
     * @param userId
     * @return
     */
    @CrossOrigin(origins = "*")
    @ResponseBody
    @RequestMapping("/bedmatHis/{vdate}/{userId}/{mit}")
    public List<Map<String, Object>> bedmatHis(@PathVariable("vdate") String vdate, @PathVariable("userId") String userId,@PathVariable("mit") Integer mit) {
        Map<String, Object> map = new HashMap<>();
        map.put("vdate", vdate);
        map.put("userId", userId);
        map.put("mit", mit);
        return hardWareService.bedmatHis(map);
    }
}
